package com.EpidemicPrevention.service;


import com.EpidemicPrevention.mapper.Help_infoMapper;

import com.EpidemicPrevention.pojo.Help_info;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class Help_infoServiceIpml implements Help_infoService{
    @Autowired
    private Help_infoMapper help_infoMapper;

    @Override
    public JSON addHelp_info(Help_info help_info) {
        JSONObject json = new JSONObject();

        int code =0;
        code =help_infoMapper.addHelp_info(help_info);
        if (code ==1){
            json.put("msg","添加成功");
            json.put("code",1);
        }else {
            json.put("msg","添加失败");
            json.put("code",0);
        }
        return json;
    }

    @Override
    public JSON deleteHelp_info(int h_id) {
        JSONObject json = new JSONObject();
        int code =0;
        code = help_infoMapper.deleteHelp_info(h_id);
        if (code ==1){
            json.put("msg","删除成功");
            json.put("code",1);
        }else {
            json.put("msg","删除失败");
            json.put("code",0);
        }
        return json;
    }

    @Override
    public JSON updateHelp_info(Help_info help_info) {
        JSONObject json = new JSONObject();

        int code=0;
        code=help_infoMapper.updateHelp_info(help_info);
        if (code==1){
            json.put("msg","修改入校信息成功");
            json.put("code",1);
        }else{
            json.put("msg","修改入校信息失败");
            json.put("code",0);
        }

        return json;
    }

    @Override
    public List<Help_info> queryHelp_info (int page, int limit, String Keyword) {
        return help_infoMapper.queryHelp_info(page, limit,null);
    }

    @Override
    public List<Help_info> selectWhereHelp_info() {
        return help_infoMapper.selectWhereHelp_info();
    }

}
